package com.atguigu.gmall.mq.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.rabbit.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: atguigu
 * @create: 2023-08-11 11:40
 */
@RestController
@RequestMapping("/api/mq")
public class ProducerController {


    @Autowired
    private RabbitService rabbitService;


    /**
     * 模拟生产者发送普通消息到指定交换机
     * @param msg
     * @return
     */
    @GetMapping("/sendNormalMsg")
    public Result sendNormalMsg(@RequestParam("msg") String msg) {
        String exhcange = "exchange.confirm";
        String routingKey = "routing.confirm";
        rabbitService.sendMsg(exhcange, routingKey, msg);
        return Result.ok();
    }
}
